﻿using Digitalmes.Application.Sys.Menus;

namespace Digitalmes.Application.Sys.Users.Queries;

/// <summary>
/// 查询用户拥有的菜单命令。
/// </summary>
/// <param name="UserId"></param>
public record GetMenusOfUserQuery(long UserId) : IRequest<IResult<List<(SysMenuDto menu, string[] roles)>>>;

internal sealed class GetMenusOfUserQueryHandler(IUserMenuApplicationService service) : IRequestHandler<GetMenusOfUserQuery, IResult<List<(SysMenuDto menu, string[] roles)>>>
{
    public async Task<IResult<List<(SysMenuDto menu, string[] roles)>>> Handle(GetMenusOfUserQuery request, CancellationToken cancellationToken)
    {
        var menus = await service.GetMenusOfUserAsync(request.UserId);
        return Result.From(menus);
    }
}
